<%@page import="models.Profil" %>
<% Profil obj = (Profil)request.getAttribute("profil");%>

<h1>Profil Toko</h1>

<div class="profil_form">
<form action="<%=request.getContextPath()%>/profil/admin" id="editprofil_form" method="POST">
    <input type="hidden" name="path_logo" value="<%= obj != null ? obj.path_logo : ""%>">
    <table class="form" id="profil_form">
        <tr>
            <td><label>Logo</label></td>
            <td><img alt=""  src="<%= request.getContextPath() + "/" + (obj != null ? obj.path_logo : "upload/not_defined.gif")%>"></td>
        </tr>
        <tr>
            <td><label for="nama_toko">Nama Perusahaan </label></td>
            <td><input type="text" name="nama_toko" value="<%= (obj != null ? obj.nama_toko : "")%>" /></td>
        </tr>
        <tr>
            <td><label for="deskripsi">Deskripsi</label></td>
            <td>
                <input type="text" name="deskripsi" value= "<%=(obj != null ? obj.deskripsi: "")%>" />
            </td>
        </tr>
        <tr>
            <td><label for="welcome_msg">Pesan Selamat Datang</label></td>
            <td>
                <input type="text" name="welcome_msg" value= "<%=(obj != null ? obj.welcome_msg: "")%>" />
            </td>
        </tr>
        <tr>
            <td><label for="alamat">Alamat</label></td>
            <td>
                <input type="text" name="alamat" value= "<%=(obj != null ? obj.alamat: "")%>" />
            </td>
        </tr>
        <tr>
            <td><label for="telepon">Telepon</label></td>
            <td>
                <input type="text" name="telepon" value= "<%=(obj != null ? obj.telepon: "")%>" />
            </td>
        </tr>
        <tr>
            <td><label for="email">Email</label></td>
            <td>
                <input type="text" name="email" value= "<%=(obj != null ? obj.email: "")%>" />
            </td>
        </tr>
        <tr>
            <td><label for="diskon">Diskon</label></td>
            <td>
                <input type="text" name="diskon" value= "<%=(obj != null ? obj.diskon: "")%>" />
            </td>
        </tr>
        <tr>
            <td></td>
            <td><input type="submit" value="Ubah Profil Toko" /></td>
        </tr>
    </table>
</form>
</div>

<div class="profil_form">
<form action="<%=request.getContextPath()%>/profil/index_uploadfoto" id="uploadlogo_form" method="POST" enctype="multipart/form-data">
    <table>
            <tr>
                <td>Image File : </td>
                <td><input type="file" name="path_logo"/></td>
            </tr>
            <tr>
                <td></td>
                <td><input type="submit" value="Update" /></td>
            </tr>
    </table>
</form>

</div>

<script>
    $(document).ready(function() {
        $("#editprofil_form").validate({
            rules : {
                nama_toko : {
                    required : true
                },
                deskripsi : {
                    required : true
                }, email : {
                    email : true
                }
            },
            messages : {
                email : "Please enter a valid email address"

            }
        });

        $("#uploadlogo_form").validate({
            rules : {
                path_logo : {
                    required : true
                }
            }
        });
    });
</script>
